<template>
	<view style="padding-bottom: 100upx;">
		<view class="bg padding-bottom">
			<view class=" u-flex padding ">
				<view class="u-m-r-10">
					<!-- @click="goNav('/pages/my/userinfo')" -->
					<image :src="shopCover" style="width: 100rpx;height: 100rpx;border-radius: 100rpx;"
						@click="goNavs(list[0].url)"></image>
				</view>
				<view class="u-flex-1 u-m-l-10 flex justify-between align-center" v-if="!isLogin">
					<view class="u-font-18  text-bold">
						<!-- #ifdef  MP-WEIXIN -->
						<view class="margin-left-sm margin-top-xs" style="width: 180px;">{{shopName}}</view>
						<!-- #endif -->
						<!-- #ifndef MP-WEIXIN -->
						<view class="margin-left-sm margin-top-xs" style="width: 180px;">{{shopName}}</view>
						<!-- #endif -->
					</view>
					<view class="erweima" @click="shopQr()">生成二维码</view>
				</view>
				<view v-else class="text-xl u-p-l-20 text-bold" @click="goLogin('/pages/my/loginphone')">
					登录
				</view>
			</view>
			<view class="moneybox" v-if="XCXIsSelect != '否'">
				<view class="padding" style="background: #FCD202;border-radius: 20upx 20upx 0upx 0upx;">
					<view class="flex justify-between">
						<view>
							<view>累计收益(元)</view>
							<view class="margin-top-xs" style="font-size: 40upx;">
								￥<text style="font-size: 55upx;">{{sumMoney}}</text></view>
						</view>
						<view>
							<view>余额(元)</view>
							<view class="margin-top-xs" style="font-size: 40upx;">
								￥<text style="font-size: 55upx;">{{money}}</text></view>
						</view>
						<view class="btn" @click="goQian()">立即提现</view>
					</view>
					<view class="flex justify-between align-center text-center margin-top">
						<view>
							<view>今日收益</view>
							<view class="margin-top-xs" style="font-size: 38upx;">
								￥<text style="font-size: 48upx;">{{dayMoney?dayMoney:'0'}}</text></view>
						</view>
						<view>
							<view>本月收益</view>
							<view class="margin-top-xs" style="font-size: 38upx;">
								￥<text style="font-size: 48upx;">{{monthMoney?monthMoney:'0'}}</text></view>
						</view>
						<view>
							<view>本月提现</view>
							<view class="margin-top-xs" style="font-size: 38upx;">
								￥<text style="font-size: 48upx;">{{cashMoney?cashMoney:'0'}}</text></view>
						</view>
					</view>
				</view>
				<view class="flex align-center justify-between padding-lr padding-tb-sm"
					style="background: #FCB202;border-radius: 0upx 0upx 20upx 20upx;">
					<view class="">每次提现平台将扣除相应手续费</view>
					<view class="xflist" @click="goNav('/my/other/cashList')">钱包明细</view>
				</view>
			</view>
		</view>

		<view class="bg margin-top-sm">
			<!-- 店铺管理 -->
			<view class="flex padding-lr padding-tb dfs" @click="goNavs(list[0].url)">
				<image :src="list[0].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[0].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>

			<!-- 陪诊师管理 -->
			<view class="flex padding-lr padding-tb dfs" @click="goNavs(list[16].url)">
				<image :src="list[16].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[16].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>



			<!-- 服务管理 -->
			<view class="flex padding-lr padding-tb dfs" @click="goNavs(list[1].url)">
				<image :src="list[1].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[1].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>
			<!-- 订单管理 -->
			<view class="flex padding-lr padding-tb" @click="goOrder()">
				<image :src="list[2].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[2].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>

			<!-- 绑定管理 -->
			<view class="flex padding-lr padding-tb dfs" @click="goNavs(list[17].url)">
				<image :src="list[17].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[17].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>


			<!-- 分类管理 -->
			<!-- <view class="flex padding-lr padding-tb" @click="goNavs(list[3].url)">
				<image :src="list[3].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[3].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
			<!-- 规格管理 -->
			<!-- <view class="flex padding-lr padding-tb" @click="goNavs(list[4].url)">
				<image :src="list[4].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[4].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
			<!-- 保证金 -->
			<view class="flex padding-lr padding-tb" @click="goNav(list[5].url)" v-if="XCXIsSelect != '否'">
				<image :src="list[5].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[5].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>
			<!-- 规格管理 -->
			<!-- <view class="flex padding-lr padding-tb" @click="goNavs(list[13].url)">
				<image :src="list[13].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[13].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
			<!-- 精选活动 -->
			<!-- <view class="flex padding-lr padding-tb" @click="goNavs(list[14].url)">
				<image :src="list[14].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[14].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
			<!-- 优惠券管理 -->
			<!-- <view class="flex padding-lr padding-tb" @click="goNavs(list[15].url)">
				<image :src="list[15].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[15].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
		</view>

		<view class="bg margin-top-sm">
			<!-- 聊天中心 -->
			<view class="flex padding-lr padding-tb dfs" @click="goNav(list[12].url)">
				<image :src="list[12].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[12].title}}</view>
				<view class="flex align-center">
					<view v-if="messageCount" class="bott">{{messageCount}}</view>
					<image src="../../static/images/my/right.png" class="images" mode=""></image>
				</view>
			</view>
			<!-- 联系客服 -->
			<!-- <view class="flex padding-lr padding-tb dfs" @click="goNav(list[6].url)">
				<image :src="list[6].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[6].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
			<!-- 关于我们 -->
			<!-- <view class="flex padding-lr padding-tb dfs" @click="goNav(list[7].url)">
				<image :src="list[7].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[7].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
			<!-- 意见反馈 -->
			<view class="flex padding-lr padding-tb dfs" @click="goNav(list[8].url)" v-if="XCXIsSelect != '否'">
				<image :src="list[8].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[8].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>
			<!-- 我的投诉 -->
			<view class="flex padding-lr padding-tb dfs" @click="goNav(list[9].url)">
				<image :src="list[9].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[9].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>
			<!-- #ifdef MP-WEIXIN -->
			<view class="flex padding-lr padding-tb dfs" @click="gouser()">
				<image :src="list[10].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[10].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>
			<!-- #endif -->
			<!-- 系统设置 -->
			<view class="flex padding-lr padding-tb dfs" @click="goset()">
				<image :src="list[11].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[11].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view>

			<!-- 退出登录 -->
			<!-- <view class="flex padding-lr padding-tb dfs" @click="TuiLogin()" v-if="!isLogin">
				<image :src="list[10].image" style="width: 50rpx;height: 50rpx;" mode=""></image>
				<view class="flex-sub margin-left text-df" style="line-height: 50upx;">{{list[10].title}}</view>
				<image src="../../static/images/my/right.png" class="images" mode=""></image>
			</view> -->
		</view>
		<u-popup v-model="show" mode="center" border-radius="14" width="500rpx" height="500rpx" :closeable="closeable">
			<view style="width: 180px;height: 180px;margin: 40px auto;">
				<image :src="shopQrImg" style="width: 100%;height: 100%;" @click="previewImage"></image>
			</view>
		</u-popup>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				shopCover: '../../static/logo.png',
				isLogin: true,
				shopName: '匿名',
				sumMoney: 0, //累计余额
				money: 0, //余额
				dayMoney: 0, //今日收益
				monthMoney: 0, //本月预估收益
				cashMoney: 0, // 本月预估提现
				shopToken: '',
				isVip: false,
				invitationCode: '', //邀请码
				list: [{
					image: '../../static/images/my/dianpu.png',
					title: '商户管理',
					url: '/my/store/index'
				}, {
					image: '../../static/images/my/shangpin.png',
					title: '服务管理',
					url: '/my/store/addgood'
				}, {
					image: '../../static/images/my/order.png',
					title: '订单管理',
					url: '/pages/order/index'
				}, {
					image: '../../static/images/my/fenlei.png',
					title: '分类管理',
					url: '/my/store/fenlei'
				}, {
					image: '../../static/images/my/guige.png',
					title: '规格管理',
					url: '/my/store/guige'
				}, {
					image: '../../static/images/my/baozhengjin.png',
					title: '保证金',
					url: '/my/other/money'
				}, {
					image: '../../static/images/my/kefu.png',
					title: '联系客服',
					url: '/pages/my/chat'
				}, {
					image: '../../static/images/my/guanyu.png',
					title: '关于我们',
					url: '/my/other/about'
				}, {
					image: '../../static/images/my/yijian.png',
					title: '意见反馈',
					url: '/my/feedback/index'
				}, {
					image: '../../static/images/my/00.png',
					title: '我的投诉',
					url: '/my/other/tousu'
				}, {
					image: '../../static/images/my/user.png',
					title: '前往用户端',
					url: ''
				}, {
					image: '../../static/images/my/set1.png',
					title: '系统设置',
					url: '/my/other/set'
				}, {
					image: '../../static/images/my/liaotian.png',
					title: '聊天中心',
					url: '/pages/my/liaotian'
				}, {
					image: '../../static/images/order/pinglun.png',
					title: '店铺评价',
					url: '/my/store/pingjia'
				}, {
					image: '../../static/images/order/hd.png',
					title: '精选活动',
					url: '/my/store/huodong'
				}, {
					image: '../../static/images/order/yhq.png',
					title: '优惠券管理',
					url: '/my/yhq/yhq'
				}, {
					image: '../../static/images/order/yhq.png',
					title: '陪诊/陪护师管理',
					url: '/my/diagnosis/index'
				}, {
					image: '../../static/images/order/bangding.png',
					title: '绑定管理',
					url: '/my/diagnosis/bindList'
				}],
				renzheng: 0,
				XCXIsSelect: '是',
				isCashDeposit: '',
				show: false,
				shopQrImg: '',
				closeable: true,
				open: true,
				arr: [],
				messageCount: ''
			}
		},
		onLoad() {
			// this.messageCount = uni.getStorageSync('messageCount')
			this.XCXIsSelect = this.$queue.getData("XCXIsSelect");
			this.shopToken = uni.getStorageSync('shopToken') ? uni.getStorageSync('shopToken') : ''
			this.userId = uni.getStorageSync('userId')
			this.open = uni.getStorageSync('open')

		},
		onShow() {
			this.shopToken = uni.getStorageSync('shopToken') ? uni.getStorageSync('shopToken') : ''
			if (this.shopToken) {
				this.messageCount = uni.getStorageSync('messageCount')
				this.isLogin = false
				this.getUserInfo()
				this.getshanghuinfo()
				this.getAmount()
			} else {
				this.isLogin = true
				this.shopName = '匿名'
				this.shopCover = '../../static/logo.png'
				this.sumMoney = 0 //累计余额
				this.money = 0 //余额
				this.dayMoney = 0 //今日收益
				this.monthMoney = 0 //本月收益
				this.cashMoney = 0 //本月提现
			}

		},
		methods: {
			previewImage() {
				var arr = [];
				arr.push(this.shopQrImg);
				//uniapp预览轮播图方法
				uni.previewImage({
					current: 0, //预览图片的下标
					urls: arr //预览图片的地址，必须要数组形式
				})
			},
			//跳转设置
			goset() {
				uni.navigateTo({
					url: '/my/other/set'
				})
			},
			//生成二维码
			shopQr() {
				// uni.showLoading({
				// 	title: '二维码生成中',
				// 	duration: 1000,
				// 	icon: 'none'
				// });
				this.show = true

				this.shopQrImg = 'https://tcwm.xianmaxiong.com/sqx_fast/invite/shopQr?shopId=' + uni.getStorageSync(
					'shopId')
			},
			//跳转用户端
			gouser() {
				wx.navigateToMiniProgram({
					appId: 'wxd6a3bf45c999d9cd',
					path: '/pages/index/index',
					envVersion: 'release', // 打开正式版
					success(res) {
						// 打开成功
					},
					fail: function(err) {
						console.log(err);
					}
				})
			},
			goQian() {
				console.log(this.shopToken);
				if (this.shopToken) {
					// #ifdef MP-WEIXIN
					if (uni.getStorageSync('sendindexMsg')) {
						uni.requestSubscribeMessage({
							tmplIds: this.arr,
							success(re) {
								console.log(re, '**********')
								var datas = JSON.stringify(re);
								if (datas.indexOf("accept") != -1) {
									console.log(re)
								}
							},
							fail: (res) => {
								console.log(res)
							}
						})
					}
					// #endif
					uni.navigateTo({
						url: '/my/other/wallet'
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/my/loginphone'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}

			},
			bindFb() {
				let renzheng = uni.getStorageSync('renzheng')
				console.log(this.userId, renzheng)

				if (this.shopToken) {
					// #ifdef MP-WEIXIN
					if (uni.getStorageSync('sendindexMsg')) {
						uni.requestSubscribeMessage({
							tmplIds: this.arr,
							success(re) {
								// console.log(re,'**********')
								var datas = JSON.stringify(re);
								if (datas.indexOf("accept") != -1) {
									console.log(re)
								}
							},
							fail: (res) => {
								console.log(res)
							}
						})
					}
					// #endif
					uni.navigateTo({
						url: '/my/publish/editor'
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/my/loginphone'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			goOrder() {
				uni.switchTab({
					url: '/pages/order/index'
				})
			},
			//列表跳转
			goNav(e, name) {
				console.log(e)
				if (this.shopToken) {
					// #ifdef MP-WEIXIN
					if (uni.getStorageSync('sendindexMsg')) {
						uni.requestSubscribeMessage({
							tmplIds: this.arr,
							success(re) {
								// console.log(re,'**********')
								var datas = JSON.stringify(re);
								if (datas.indexOf("accept") != -1) {
									console.log(re)
								}
							},
							fail: (res) => {
								console.log(res)
							}
						})
					}
					// #endif
					uni.navigateTo({
						url: e
					})
				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/my/loginphone'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			//列表跳转
			goNavs(e, name) {
				console.log(this.shopToken)
				let cashDeposit = uni.getStorageSync("cashDeposit")
				if (this.shopToken) {
					// #ifdef MP-WEIXIN
					if (uni.getStorageSync('sendindexMsg')) {
						uni.requestSubscribeMessage({
							tmplIds: this.arr,
							success(re) {
								console.log(re, '**********')
								var datas = JSON.stringify(re);
								if (datas.indexOf("accept") != -1) {
									console.log(re)
								}
							},
							fail: (res) => {
								console.log(res)
							}
						})
					}
					// #endif
					if (cashDeposit == 0 || cashDeposit == 'null') {
						uni.showModal({
							title: '提示',
							content: '您还未缴纳保证金，请先去缴纳保证金',
							success: function(res) {
								if (res.confirm) {
									console.log('用户点击确定');
									uni.navigateTo({
										url: '/my/other/money'
									})
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
					} else {
						uni.navigateTo({
							url: e
						})
					}
					uni.navigateTo({
						url: e
					})

				} else {
					uni.showModal({
						title: '提示',
						content: '您还未登录,请先登录',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateTo({
									url: '/pages/my/loginphone'
								})
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			goLogin(e) {
				uni.navigateTo({
					url: e
				})
			},
			//我的收益
			getAmount() {
				let data = {
					shopId: uni.getStorageSync('shopId')
				}
				this.$Request.get("/admin/shop/shopEarnings", data).then(res => {
					if (res.code == 0) {
						this.sumMoney = parseFloat(res.data.shopAllEarnings).toFixed(2) //累计余额
						this.money = parseFloat(res.data.shopMoney).toFixed(2) //余额
						this.dayMoney = parseFloat(res.data.shopEarningsDay).toFixed(2) //今日收益
						this.monthMoney = parseFloat(res.data.shopEarningsMonth).toFixed(2) //本月收益
						this.cashMoney = parseFloat(res.data.cashMoney).toFixed(2) //本月提现
					}
				});
			},
			getshanghuinfo() {
				let data = {
					shopId: uni.getStorageSync('shopId')
				}
				this.$Request.get("/admin/shop/selectShopMessage", data).then(res => {
					if (res.code == 0) {
						uni.setStorageSync('cashDeposit', res.data.cashDeposit)
					}
				});
			},
			selectShop(e) {
				this.shop = e
				this.show = false

			},

			goNav(url) {
				if (this.shopToken) {
					// #ifdef MP-WEIXIN
					if (uni.getStorageSync('sendindexMsg')) {
						uni.requestSubscribeMessage({
							tmplIds: this.arr,
							success(re) {
								// console.log(re,'**********')
								var datas = JSON.stringify(re);
								if (datas.indexOf("accept") != -1) {
									console.log(re)
								}
							},
							fail: (res) => {
								console.log(res)
							}
						})
					}
					// #endif
					uni.navigateTo({
						url
					})
				} else {
					uni.navigateTo({
						url: '/pages/my/loginphone'
					})
				}
			},
			getUserInfo() {
				this.$Request.getA("/sys/user/info").then(res => {
					if (res.code == 0) {
						// this.shopName = res.user.shopList[0].shopName
						// this.shopCover = res.user.shopList[0].shopCover ? res.user.shopList[0].shopCover : '../../static/logo.png'

						this.shopName = res.user.userEntity.userName
						this.shopCover = res.user.userEntity.avatar ? res.user.userEntity.avatar :
							'../../static/logo.png'

						this.$queue.setData('avatar', res.user.shopList[0].shopCover);
						this.$queue.setData("userId", res.user.userId);
						this.$queue.setData("shopId", res.user.shopList[0].shopId);
						this.$queue.setData("mobile", res.user.mobile);
						this.$queue.setData("shopUserName", res.user.shopList[0].shopName);
						if (res.user.userEntity) {
							this.$queue.setData("zhiFuBao", res.user.userEntity.zhiFuBao);
							this.$queue.setData("zhiFuBaoName", res.user.userEntity.zhiFuBaoName);
						}

					}
				});
			},


		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F2F2F2;
	}

	.bg {
		background: #FFFFFF;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.btn-bg {
		width: 64px;
		height: 28px;
		background: linear-gradient(90deg, #CDA26E 0%, #DCB78A 100%);
		border-radius: 28px;
		text-align: center;
		line-height: 28px;
		margin-top: 4px;
		color: '#604320'
	}

	.images {
		width: 18rpx;
		height: 30rpx;
	}

	.dfs {
		display: flex;
		align-items: center;
	}

	.moneybox {
		width: 690upx;
		margin: 0 auto;
		// height: 369upx;
		// background: #2FB57A;
		border-radius: 20upx 20upx 20upx 20upx;

	}

	.btn {
		width: 160upx;
		height: 60upx;
		background: linear-gradient(90deg, #3D3734 0%, #252323 100%);
		border-radius: 50upx;
		text-align: center;
		line-height: 60upx;
		color: #FFFFFF;
	}

	.xflist {
		width: 150upx;
		height: 50upx;
		background: #211D2C;
		color: #FFFFFF;
		border-radius: 5upx;
		text-align: center;
		line-height: 50upx;
	}

	.erweima {
		background: #FCD202;
		padding: 5px 10px;
		border-radius: 20px;
	}

	.bott {
		background: red;
		color: #ffffff;
		width: 30upx;
		height: 30upx;
		text-align: center;
		line-height: 26upx;
		padding: 5rpx;
		border-radius: 60%;
		font-size: 23rpx;
		margin-right: 15rpx;
	}
</style>